import request from "@/assets/js/request";
import util from "@/assets/js/public";
import { getToken } from '@/assets/js/auth';
import Vue from "vue";

//获取二级栏目详细数据
export function findAllForum(params){
    return request({
        url:process.env.VUE_APP_URL + '/action/openapi/bps/common/transmit/us$content$api$findAllForum?source=MOBILE',
        contentType:'application/json;charset=UTF-8',
        data:{
            "access_token":getToken(),
            "appCode":"yglt",
            "currentUserCode":util.encrypt(params.userName),
            "versionName":"2.7.92",
            "source":'MOBILE',
            "noAction":'1',  
            "kv":{
                "currentUserCode":util.encrypt(params.userName),
                "source":'MOBILE',
                "isFlag":'1',
                "page":params.listQuery.page,
                "rows":params.listQuery.rows,
                "size":params.listQuery.size,
                "direction":params.listQuery.direction,
                "properties":params.listQuery.properties,
            },
            "jsonName":'appDecision',
            "appDecision":params.fromdetaildata
        }
    })
}
//字典查询
export function queryByType(params){
    return request({
        url:process.env.VUE_APP_URL + '/action/openapi/bps/common/transmit/action$queryDictValue$api$queryByType?source=MOBILE',
        contentType:'application/json;charset=UTF-8',
        data:{
            "access_token":getToken(),
            "appCode":"yglt",
            "currentUserCode":util.encrypt(params.userName),
            "versionName":"2.7.92",
            "source":'MOBILE',
            "noAction":'1',  
            "kv":{
                "currentUserCode":util.encrypt(params.userName),
                "source":'MOBILE',
                "isFlag":'1',
                "dictType":params.dictType,
            },
            "jsonName":'appDecision',
            // "appDecision":params.fromdetaildata
        }
    })
}
//获取评论信息
export function findContentComment(params){
    return request({
        url:process.env.VUE_APP_URL + '/action/openapi/bps/common/transmit/us$comment$api$findContentComment?source=MOBILE',
        contentType:'application/json;charset=UTF-8',
        data:{
            "access_token":getToken(),
            "appCode":"yglt",
            "currentUserCode":util.encrypt(params.userName),
            "versionName":"2.7.92",
            "source":'MOBILE',
            "noAction":'1',  
            "kv":{
                "currentUserCode":util.encrypt(params.userName),
                "source":'MOBILE',
                "isFlag":'1',
                "id":params.id,
                "page":'1',
                "rows":'100',
                "size":'100',
            },
        }
    })
}
//点赞点踩
export function supportCreate(params){
    return request({
        url:process.env.VUE_APP_URL + '/action/openapi/bps/common/transmit/us$support$api$create1?source=MOBILE',
        contentType:'application/json;charset=UTF-8',
        data:{
            "access_token":getToken(),
            "appCode":"yglt",
            "currentUserCode":util.encrypt(params.userName),
            "versionName":"2.7.92",
            "source":'MOBILE',
            "noAction":'1',  
            "kv":{
                "currentUserCode":util.encrypt(params.userName),
                "source":'MOBILE',
                "isFlag":'1',
                "fromAccount":params.userName,
                "isOppose":params.isOppose,
                "toContent":params.toContent,
                "typeId":params.typeId,
                "typeName":params.typeName,
            },
            "jsonName":'appDecision',
            "appDecision":{
                "fromAccount":params.userName,
                "isOppose":params.isOppose,
                "toContent":params.toContent,
                "typeId":params.typeId,
                "typeName":params.typeName,
            }
        }
    })
}
//删除点赞点踩
export function deleteSupport(params){
    return request({
        url:process.env.VUE_APP_URL + '/action/openapi/bps/common/transmit/us$support$api$deleteSupport?source=MOBILE',
        contentType:'application/json;charset=UTF-8',
        data:{
            "access_token":getToken(),
            "appCode":"yglt",
            "currentUserCode":util.encrypt(params.userName),
            "versionName":"2.7.92",
            "source":'MOBILE',
            "noAction":'1',  
            "kv":{
                "currentUserCode":util.encrypt(params.userName),
                "source":'MOBILE',
                "isFlag":'1',
            },
            "jsonName":'appDecision',
            "appDecision":{
                "fromAccount":params.userName,
                "toContent":params.toContent,
                // "isOppose":params.isOppose,
                // "typeId":params.typeId,
                // "typeName":params.typeName,
            }
        }
    })
}
//根据id获取单个话题信息
export function findById(params){
    return request({
        url:process.env.VUE_APP_URL + '/action/openapi/bps/common/transmit/us$content$api$findById1?source=MOBILE',
        contentType:'application/json;charset=UTF-8',
        data:{
            "access_token":getToken(),
            "appCode":"yglt",
            "currentUserCode":util.encrypt(params.userName),
            "versionName":"2.7.92",
            "source":'MOBILE',
            "noAction":'1',  
            "kv":{
                "currentUserCode":util.encrypt(params.userName),
                "source":'MOBILE',
                "isFlag":'1',
                "id":params.id,
            },
        }
    })
}
//阅读量加一
export function displayOrderUpdate(params){
    return request({
        url:process.env.VUE_APP_URL + '/action/openapi/bps/common/transmit/us$content$api$update1?source=MOBILE',
        contentType:'application/json;charset=UTF-8',
        data:{
            "access_token":getToken(),
            "appCode":"yglt",
            "currentUserCode":util.encrypt(params.userName),
            "versionName":"2.7.92",
            "source":'MOBILE',
            "noAction":'1',  
            "kv":{
                "currentUserCode":util.encrypt(params.userName),
                "source":'MOBILE',
                "isFlag":'1',
            },
            "jsonName":'appDecision',
            "appDecision":{
                "displayOrder":params.displayOrder,
                "id":params.id,
            }
        }
    })
}

//评论和回复
export function create(params){
    return request({
        url:process.env.VUE_APP_URL + '/action/openapi/bps/common/transmit/us$comment$api$create1?source=MOBILE',
        contentType:'application/json;charset=UTF-8',
        data:{
            "access_token":getToken(),
            "appCode":"yglt",
            "currentUserCode":util.encrypt(params.userName),
            "versionName":"2.7.92",
            "source":'MOBILE',
            "noAction":'1',  
            "kv":{
                "currentUserCode":util.encrypt(params.userName),
                "source":'MOBILE',
                "isFlag":'1',
            },
            "jsonName":'appDecision',
            "appDecision":params.appDecision
        }
    })
}